package com.dwxt.sport.business.entity;

import com.dwxt.sport.constant.CommonConstant;
import com.dwxt.sport.util.DictUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import java.time.LocalDateTime;

@Data
@Accessors(chain = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
@Table(name = "t_alarm_info")
public class AlarmInfo {

    @Id
    private String id;

    /**
     * 街道id
     */
    @Column(name = "street_id")
    private String streetId;

    /**
     * 设备名称
     */
    private String name;

    /**
     * 设备类型
     */
    @Column(name = "device_type")
    private String unitType;

    @ApiModelProperty("设备类型Display")
    public String getUnitTypeDisplay(){
        return unitType!=null? DictUtil.getDisplay("deviceType",unitType):null;
    }

    /**
     * 设备位置
     */
    @Column(name = "device_location")
    private String deviceLocation;

    /**
     * 报警类型
     */
    @Column(name = "alarm_type")
    private String alarmType;

    @ApiModelProperty("设备类型Display")
    public String getAlarmTypeDisplay(){
        return alarmType!=null? DictUtil.getDisplay("alarmType",alarmType):null;
    }

    /**
     * 报警时间
     */
    @Column(name = "alarm_time")
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    @ApiModelProperty("报警时间")
    private LocalDateTime alarmTime;

    /**
     * 报警原因
     */
    @Column(name = "cause_of_alarm")
    private String causeOfAlarm;

    /**
     * 图片地址
     */
    @Column(name = "img_url")
    private String imgUrl;

    public String getImgUrl(){
        return imgUrl==null?null: CommonConstant.FILE_SERVER+imgUrl;
    }

    /**
     * 报警状态
     */
    @Column(name = "alarm_state")
    private String alarmState;

    @ApiModelProperty("报警状态Display")
    public String getAlarmStateDisplay(){
        return alarmState!=null? DictUtil.getDisplay("alarmState",alarmState):null;
    }

    /**
     * 逻辑删除标识(0否1是)
     */
    @Column(name = "is_delete")
    private String isDelete;

    /**
     * 创建时间
     */
    @Column(name = "create_time")
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    @ApiModelProperty("创建时间")
    private LocalDateTime createTime;

    /**
     * 创建人id
     */
    @Column(name = "create_user_id")
    private String createUserId;

    /**
     * (最近)更新时间
     */
    @Column(name = "update_time")
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    @ApiModelProperty("(最近)更新时间")
    private LocalDateTime updateTime;

    /**
     * 更新人id
     */
    @Column(name = "update_user_id")
    private String updateUserId;

    /**
     * 备用字段1
     */
    private String attr1;

    /**
     * 备用字段2
     */
    private String attr2;

    /**
     * 备用字段3
     */
    private String attr3;

}